# @Author: dyiwen
# @Date:   2020-09-22 15:56:44
# @Last Modified by:   dyiwen
# @Last Modified time: 2020-09-22 17:42:27
#Add my own tab automatic completion
function _harborctl_tool() {
    COMPREPLY=()
    local cur=${COMP_WORDS[COMP_CWORD]};
    local com=${COMP_WORDS[COMP_CWORD-1]};
    case $com in
    'harborctl')
        COMPREPLY=($(compgen -W 'check get search login logout' -- $cur))
        ;;
    'get')
        COMPREPLY=($(compgen -W 'project repo image' -- $cur))
        ;;
    'search')
        COMPREPLY=($(compgen -W 'repo image' -- $cur))
        ;;
    'image')
        COMPREPLY=($(compgen -W '-p -t -s -i -h' -- $cur))
        ;;
    'repo')
        COMPREPLY=($(compgen -W '-p -s -i -h' -- $cur))
        ;;
    *)
        ;;
    esac
    return 0
}
complete -F _harborctl_tool harborctl
